#ifndef DATAFRAME_H
#define DATAFRAME_H

#include <QList>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <utility>
#include <QHash>

class DataFrame
{
private:
    QString filePath;
    int chunk_size;
    QFile* handle;
    QTextStream *stream;

    void close(){
        if(handle){
            delete handle;
            handle = nullptr;
            chunk_size = -1;
            if(stream){
                delete stream;
                stream = nullptr;
            }
        }
    }

public:
    DataFrame();
    DataFrame(const DataFrame&) = delete;
    DataFrame(DataFrame&& other);

    ~DataFrame();

    DataFrame& operator=(const DataFrame&) = delete;

    bool operator==(const QString& path) const
    {
        if(isLoaded())
            return filePath == path;

        return false;
    }

    bool operator!=(const QString& path) const
    {
        return !this->operator == (path);
    }

    bool load(const QString& filePath, int size);
    bool isLoaded() const
    {
        if(handle && stream)
            return true;

        return false;
    }
    QVariantList get_chunk(int size = -1);
    QHash<QString, QVariantList> get_chunk (int size, int left);
};


#endif // DATAFRAME_H
